﻿@model KhuyenMaiVang.DAL.Voucher

@{
    ViewBag.Title = "VoucherDetail";
    Layout = "~/Views/Shared/_LayoutHome.cshtml";
}

<div class="deal-detail">
    <div class="deal-main-info box-item detail-box1">
      <p>
          <span class="detail-deal-title">@Model.Title :</span>
          @Model.Description
      </p>
      <div class="detail-advertise-box">
          <div class="detail-deal-buy">
              <div class="detail-buy">
                  <span class="detail-deal-price">
                  @{
                      var sell = "?";
                      if( Model.SellPrice.HasValue)
                      {
                          sell = Model.SellPrice.Value.ToString("#,#.#");
                      }
                   }
                    @sell <br />VND
                  </span>
                  <span class="detail-deal-buy-button">
                      @Html.ActionLink(" ",  "VoucherDetail","Home", new { id = Model.ID }, null)
                  </span>
                  <div style="clear:both"></div>
              </div>
              <div class="detail-cost">
                        @{
                            String cost = "?";
                            if(Model.CostPrice.HasValue){
                                cost =  Model.CostPrice.Value.ToString("#,#.#");
                            }                        
                        }
                    <span class="detail-title">Giá gốc : </span>
                    <span class="detail-value value-cost">@cost VND</span>
              </div>
              <div class="detail-save">
                     @{
                        String save = "?";
                        if (Model.CostPrice.HasValue && Model.CostPrice != 0 && Model.SellPrice.HasValue)
                        {
                            save = ((1 - Model.SellPrice / Model.CostPrice) * 100).Value.ToString("#,#.#");                            
                        }   
                    }
                    <span class="detail-title">Tiết kiệm:</span> 
                    <em>@save</em>%
              </div>
              <div class="detail-bought">
                  <span class="detail-title">Số người đã mua :</span>
                  <span class="detail-value">CCDL</span>
              </div>
              <div class="timeout">
                  @{
                      TimeSpan timeout = new TimeSpan(0);
                      if(Model.EndTime.HasValue)
                      {
                         timeout = (Model.EndTime.Value - DateTime.Now);
                      }
                  }
                  <span class="detail-title">Thời gian còn lại : </span><br />
                  <div class="clockCountDown" >
                    <span class="clock-days">@timeout.Days</span>
                    <span class="clock-hours">@timeout.Hours</span>
                    <span class="clock-minutes">@timeout.Minutes</span>
                    <span class="clock-seconds">@timeout.Seconds</span>
                  </div>
              </div>
          </div>
          <div class="slideshow">
              <img class="detail-image" src="@Model.Thumb" alt="@Model.Thumb" />
              <div class="list-image">
                <span class="first-image" > </span>
                <img class="imageshow currentshow" src="@(Model.Thumb)" alt="@(Model.Thumb)" style="display:block" index="0"/>
                @if (Model.Pictures != null) 
                {
                    int count = Model.Pictures.Count;
                    KhuyenMaiVang.Models.PagingModel imagePaging = new KhuyenMaiVang.Models.PagingModel("","",null,0,count,5,5);
                    for (int i = 0; i < count; i++)
                    {
                        string display = "block";
                        if (i > 3)
                        {
                            display = "none";
                        }

                        var pic = Model.Pictures.ElementAt(i);
                        <img class="imageshow" src="@(pic.URL)" alt="@(pic.URL)" style="display:@(display)" index="@(i+1)"/> 
                    }
                }
                <span class="last-image"></span>
              </div>
              <div style="clear: both"></div>
          </div>
        <div style="clear:both"></div>
      </div>
    </div>
    <div class="deal-more-info box-item detail-box2">
        <div class="detail-features">
            <p class="title">ĐIỂM NỔI BẬT</p>
            @Html.Raw(Model.Features)
        </div>
        <div class="detail-reqiures">
            <p class="title">YÊU CẦU</p>
            @Html.Raw(Model.Requirements)
        </div>
        <div style="clear:both"></div>
    </div>
    <div class="deal-body-contaner box-item detail-box3">
        <div class="deal-addresses">
                <div class="company-container">
                    @if(Model.Business != null && Model.Business.User != null)
                    {
                      <span class="company-title">Công ty : </span> @Model.Business.User.DisplayName
                    }
                </div>
                @if (Model.AddressVouChers != null)
                {
                    <ul >
                    @foreach (var address in Model.AddressVouChers)
                    {
                        if (address.Address != null)
                        {
                            <li>
                                @address.Address.Name <br />
                                <span class="bntView" onclick="onClickItem('@address.Address.Name','@address.Address.Longitude','@address.Address.Latitude')"></span>
                            </li>
                        }
                    }
                    </ul>
                }
        </div>
        <div class="deal-body box-item"> 
            @Html.Raw(Model.Body)
        </div>
        <div style="clear:both"></div>
    </div>
    <div class="deal-comment box-item detail-box4">
        Bình luận<br />
        <textarea>  
        </textarea>
        <div>
            @if (Model.Comments != null) 
            {
                foreach (var comment in Model.Comments)
                { 
                    <div>
                        <div class="user-comment">
                            <img class="img-avata" src="@(comment.User.Avatar)" alt="@(comment.User.DisplayName)"/>
                        </div>
                        <p class="body-comment">
                            @comment.Body
                        </p>
                    </div>
                    <div style="clear:both"></div>
                }
            }
        </div>
    </div>
</div>
<div id="dialog">
    <img />
</div>
<script src="@Url.Content("~/Scripts/Custom/slideshow.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Custom/ClockCountDown2.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Custom/MapView.js")" type="text/javascript"></script>
